Link problem

I have a question.

I have a big dxl here, he does a lot of things but one of them is not working very well.

I wanna to get the information from an attribute from another module requirement in which the current module requirement is linked to. So far its okay. 
But the problem is when it have more than one link. I wanna to get the requirement that have the higher answer. For example, this attribute have the variables "A", "B", "C" etc...and if the current module requirement is linked to one requirement with the attribute with "C" as an answer and to another with "A" as an answer...I just want to show the one with the "A" answer.

If someone have some idea I would like to read. Thanks!

 

for funcLink in reqmtObj->"Func to" do {
funcMod = target funcLink
 
if (!(open(funcMod))) {
put(modulesToClose, fullName(funcMod), fullName(funcMod))
}
read(fullName(funcMod), false)
}
 
for funcLink in reqmtObj->"Func to" do {
funcObj = target funcLink
 
if (null funcObj) {
break
}
funcObj."Function DAL" ""
 
}
set(functionDALField, funcObj."Function DAL" "")

braolive - Thu Sep 19 13:01:06 EDT 2013

Re: Link problem
llandale - Thu Sep 19 13:11:22 EDT 2013

Inside, at bottom of loop:

  •    Value_Current = funcObj."Function DAL" ""
  •    if (null Value_Best or Value_Current is better than Value_Best) then Value_Best = Value_Current
  • }
  • set(functionDALField, Value_Best)

-Louie

 

Re: Link problem
braolive - Fri Sep 20 10:15:27 EDT 2013

llandale - Thu Sep 19 13:11:22 EDT 2013

Inside, at bottom of loop:

  •    Value_Current = funcObj."Function DAL" ""
  •    if (null Value_Best or Value_Current is better than Value_Best) then Value_Best = Value_Current
  • }
  • set(functionDALField, Value_Best)

-Louie

 

I almost get it...but I think I didnt get it right...if you can look and tell me what im doing wrong I would appreciate it.

  for funcLink in reqmtObj->"Func to" do {
funcMod = target funcLink
 
if (!(open(funcMod))) {
put(modulesToClose, fullName(funcMod), fullName(funcMod))
}
read(fullName(funcMod), false)
}
 
for funcLink in reqmtObj->"Func to" do {
funcObj = target funcLink
 
if (null funcObj) {
break
}
 
        Value_Current = first(funcObj)
Value_Best = last(funcObj)
 
    if (null Value_Best)  {
Value_Best = Value_Current
}
if (Value_Current > Value_Best){
Value_Best = Value_Current
}
}
set(functionDALField, Value_Best)
 

If you dont, its ok...your first hint gave me a light.

Thanks!

Re: Link problem
llandale - Fri Sep 20 12:03:08 EDT 2013

braolive - Fri Sep 20 10:15:27 EDT 2013

I almost get it...but I think I didnt get it right...if you can look and tell me what im doing wrong I would appreciate it.

  for funcLink in reqmtObj->"Func to" do {
funcMod = target funcLink
 
if (!(open(funcMod))) {
put(modulesToClose, fullName(funcMod), fullName(funcMod))
}
read(fullName(funcMod), false)
}
 
for funcLink in reqmtObj->"Func to" do {
funcObj = target funcLink
 
if (null funcObj) {
break
}
 
        Value_Current = first(funcObj)
Value_Best = last(funcObj)
 
    if (null Value_Best)  {
Value_Best = Value_Current
}
if (Value_Current > Value_Best){
Value_Best = Value_Current
}
}
set(functionDALField, Value_Best)
 

If you dont, its ok...your first hint gave me a light.

Thanks!

  • Value_Current = first(funcObj)
  • Value_Best = last(funcObj)

Got no idea what those two lines are about; getting the 1st and last children 'Object's of the linked object?

Don't forget to declare strings Value_Current and Value_Best

Re: Link problem
braolive - Fri Sep 20 12:39:17 EDT 2013

llandale - Fri Sep 20 12:03:08 EDT 2013

  • Value_Current = first(funcObj)
  • Value_Best = last(funcObj)

Got no idea what those two lines are about; getting the 1st and last children 'Object's of the linked object?

Don't forget to declare strings Value_Current and Value_Best

I declared them.
What I'm trying to do is this:
My requirement is linked to two different requirements, requirement A and requirement B
I triied to make the Value_Current get the value of funcObj. "DAL Function" of the requirement  A and the Value_Best to get the value of the same attribute from the requirement B...

In the dxl above I forget to specify that

funcObj = target funcLink
funcObj."Function DAL" ""

Then compare.

What DOORS tells me is that this part

if (Value_Current > Value_Best){
Value_Best = Value_Current
   }
}
set(functionDALField, Value_Best)

is wrong, but nothing more

Re: Link problem
llandale - Fri Sep 20 13:20:56 EDT 2013

braolive - Fri Sep 20 12:39:17 EDT 2013

I declared them.
What I'm trying to do is this:
My requirement is linked to two different requirements, requirement A and requirement B
I triied to make the Value_Current get the value of funcObj. "DAL Function" of the requirement  A and the Value_Best to get the value of the same attribute from the requirement B...

In the dxl above I forget to specify that

funcObj = target funcLink
funcObj."Function DAL" ""

Then compare.

What DOORS tells me is that this part

if (Value_Current > Value_Best){
Value_Best = Value_Current
   }
}
set(functionDALField, Value_Best)

is wrong, but nothing more

[A] "is wrong, but nothing more".  Wrong.  It gives a pretty specific error message and a particular line of code.  You should post the error and tell us which line of code it is.  In this case it appears that "Value_Best" has been implicitely defined as type "Object" because further up you did this:

  • Value_Best = last(funcObj)

[B] This line of code retrieves the value and converts it to a string, but doesn't store it.  Effectively it does nothing:

  • funcObj."Function DAL" ""

[C] Turn off autodeclare.  It is a disaster.  Search for "auto declare" in the DXL manual.

[D] I thought you wanted to poll all linked requirements and set the current object value to the "best" one.  I think "best" is the one with the lowest character; "B" is better than "C".  Since you can have zero or more (and very many) linked requirements it would not make sense to capture all the values and then compare them.  Instead you get "this" requiirement's value, and if it is better than the current best one then update the best value.  Perhaps it better to name "best" value "Best_Value_So_Far".

  • string Best_Value_So_Far = "", Value_Current = ""
  • for each link
  • {  Value_Current = value from target object
  •    if (Value_Current is better than Best_Value_So_Far) then Best_Value_So_Far = Value_Current
  • }
  • set current object value to Best_Value_So_Far.

For you, I think, the compare is:

  • if (Value_Current < Best_Value_So_Far)

[E] If you want to REMEMBER which linked Requirment Object is "Best":

  • string Best_Value_So_Far = "", Value_Current = ""
  • Object oBest = null
  • for each link
  • {  Value_Current = value from target object
  •    if (Value_Current is better than Best_Value_So_Far) then
  •    {  Best_Value_So_Far = Value_Current
  •        oBest = reqmtObj
  •    }
  • }
  • if (!null oBest) then oBest is your "Best" linked requirement; deal with it

-Louie